﻿package util
{

	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.filters.BlurFilter;
	import flash.filters.GlowFilter;
	import flash.system.ApplicationDomain;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;

	public class DisplayUtil
	{

		public static function removeChild(parent:DisplayObjectContainer, target:DisplayObject):void
		{
			if(parent != null && target != null && parent.contains(target))
			{
				parent.removeChild(target);
			}
		}

		public static function removeAllChild(parent:DisplayObjectContainer, forever:Boolean = false):void
		{
			if(parent != null)
			{
				while(parent.numChildren > 0)
				{
					var child:DisplayObject = parent.getChildAt(0);
					parent.removeChild(child);

					if(forever)
					{
						child = null;
					}
				}
			}
		}

		public static function addChild(child:DisplayObject, parent:DisplayObjectContainer):void
		{
			if(child != null && parent != null)
			{
				parent.addChild(child);
			}
		}

		public static function addChildAt(child:DisplayObject, parent:DisplayObjectContainer, index:int):void
		{
			if(index >= 0 && child != null && parent != null)
			{
				parent.addChildAt(child, index);
			}
		}

		public static function removeChildAt(parent:DisplayObjectContainer, index:int):void
		{
			if(parent != null)
			{
				parent.removeChildAt(index);
			}
		}

	/*public static function getMC(dm:ApplicationDomain, name:String):void
	   {

	 }*/
	}
}
